package com.matrix.capp.matrix_capp

import android.os.Bundle
import android.os.SystemClock
import android.util.Log
import io.flutter.embedding.android.FlutterActivity
import io.flutter.Log as FlutterLog

class MainActivity: FlutterActivity() {
    private val TAG = "FlutterInit"
    private var startTime = 0L
    
    init {
        // 强制启用所有级别的日志
        FlutterLog.setLogLevel(FlutterLog.VERBOSE)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        startTime = SystemClock.elapsedRealtime()
        super.onCreate(savedInstanceState)
        FlutterLog.d(TAG, "FlutterActivity onCreate started")
        Log.d(TAG, "FlutterActivity onCreate started")
    }

    override fun onResume() {
        super.onResume()
        val elapsed = SystemClock.elapsedRealtime() - startTime
        FlutterLog.d(TAG, "FlutterActivity onResume started (${elapsed}ms)")
        Log.d(TAG, "FlutterActivity onResume started (${elapsed}ms)")
    }

    override fun onFlutterUiDisplayed() {
        super.onFlutterUiDisplayed()
        val elapsed = SystemClock.elapsedRealtime() - startTime
        FlutterLog.d(TAG, "Flutter UI successfully displayed after ${elapsed}ms")
        Log.d(TAG, "Flutter UI successfully displayed after ${elapsed}ms")
    }

    override fun onFlutterUiNoLongerDisplayed() {
        super.onFlutterUiNoLongerDisplayed()
        FlutterLog.d(TAG, "Flutter UI no longer displayed")
        Log.d(TAG, "Flutter UI no longer displayed")
    }
}
